public class Demo {
    static int count = 0;
    public static void main(String[] args) throws InterruptedException {
        String locker = new String();
        Thread thread = new Thread(()->{
            synchronized (locker){
                for (int i = 0; i < 5000; i++) {
                    count++;
                }
            }
        });
        Thread thread1 = new Thread(()->{
            synchronized (locker){
                for (int i = 0; i < 5000; i++) {
                    count++;
                }
            }
        });
        thread.start();
        thread1.start();

        thread.join();
        thread1.join();
        System.out.println("count = "+count);
    }
}
